package logic

import (
	"activity_srv/activity"
	"activity_srv/internal/dao"
	"activity_srv/internal/svc"
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type BargainHelpLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewBargainHelpLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BargainHelpLogic {
	return &BargainHelpLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 帮砍接口
func (l *BargainHelpLogic) BargainHelp(in *activity.BargainHelpRequest) (*activity.BargainHelpResponse, error) {
	help, err := dao.BargainHelp(in.Code, int32(in.UserId))
	if err != nil {
		pkg.Error("砍价失败", zap.Error(err))
		return nil, err
	}
	return &activity.BargainHelpResponse{
		Message: "成功",
		Price:   help,
	}, nil
}
